<!--查看专业班次学员信息统计-->
<template>
  <div>
    <div style="display: flex;">
      <div class="report-button" style="width: 110px; background: #FCF2EA; border: 1px solid #DD6D1A; color: #DD6D1A;" @click="handleClassReport">
        <span>班学员统计</span>
      </div>
      <div class="report-button" style="width: 130px; background: #F0F9FF; border: 1px solid #5EADE9; color: #5EADE9;" @click="handleExistReport">
        <span>现有学员信息</span>
      </div>
      <div class="report-button" style="width: 140px; background: #FFF6F0; border: 1px solid #E9B535; color: #E9B535;" @click="handleTransferMajorReport">
        <span>转专业学员信息</span>
      </div>
      <div class="report-button" style="width: 130px; background: #FFF4FA; border: 1px solid #DD268D; color: #DD268D;" @click="handleDropReport">
        <span>退学学员信息</span>
      </div>
      <div class="report-button" style="width: 130px; background: #F1FFFA; border: 1px solid #04C670; color: #04C670;" @click="handlePunishReport">
        <span>处罚学员信息</span>
      </div>
      <div class="report-button" style="width: 130px; background: #FFEEEF; border: 1px solid #FA533C; color: #FA533C;" @click="handleRewardReport">
        <span>奖励学员信息</span>
      </div>
      <div class="report-button" style="width: 130px; background: #EFEBFF; border: 1px solid #624CC5; color: #624CC5;" @click="handleDemotionReport">
        <span>降级学员信息</span>
      </div>
      <div class="report-button" style="width: 130px; background: #FDFEEB; border: 1px solid #8A9E13; color: #8A9E13;" @click="handleTransferSchoolReport">
        <span>转学学员信息</span>
      </div>
    </div>
    <div v-if="tableIndex === 1" style="margin-top: 20px;">
      <el-table :data="tableData_class" class="xpaas-table-class" row-class-name="xpaas-row-class" cell-class-name="xpaas-cell-class" header-row-class-name="xpaas-header-row-class" header-cell-class-name="xpaas-header-cell-class">
        <el-table-column prop="studentsum" label="现有学员数" align="center" sortable />
        <el-table-column prop="zzysum" label="转专业数" align="center" sortable />
        <el-table-column prop="txsum" label="退学数" align="center" sortable />
        <el-table-column prop="cfsum" label="处罚数" align="center" sortable />
        <el-table-column prop="jlsum" label="奖励数" align="center" sortable />
        <el-table-column prop="jjsum" label="降级数" align="center" sortable />
        <el-table-column prop="zxsum" label="转学数" align="center" sortable />
      </el-table>
    </div>
    <div v-if="tableIndex === 2" style="margin-top: 20px;">
      <el-table :data="tableData_exist" class="xpaas-table-class" row-class-name="xpaas-row-class" cell-class-name="xpaas-cell-class" header-row-class-name="xpaas-header-row-class" header-cell-class-name="xpaas-header-cell-class">
        <el-table-column prop="studentCode" label="学号" align="center" sortable />
        <el-table-column prop="studentName" label="姓名" align="center" sortable />
        <el-table-column prop="gender" label="性别" align="center" sortable />
        <el-table-column prop="birthday" label="出生日期" align="center" sortable />
        <el-table-column prop="zy" label="专业" align="center" sortable />
        <el-table-column prop="specialtyClassName" label="专业班次" align="center" sortable />
      </el-table>
    </div>
    <div v-if="tableIndex === 3" style="margin-top: 20px;">
      <el-table :data="tableData_transferMajor" class="xpaas-table-class" row-class-name="xpaas-row-class" cell-class-name="xpaas-cell-class" header-row-class-name="xpaas-header-row-class" header-cell-class-name="xpaas-header-cell-class">
        <el-table-column prop="studentCode" label="学号" align="center" sortable />
        <el-table-column prop="studentname" label="姓名" align="center" sortable />
        <el-table-column prop="xspecilty" label="现专业" align="center" sortable />
        <el-table-column prop="zybc" label="现专业班次" align="center" sortable />
        <el-table-column prop="reason" label="原因" align="center" sortable />
        <el-table-column prop="originalSpecialty" label="原专业" align="center" sortable />
        <el-table-column prop="originalSpecialtyClassName" label="原专业班次" align="center" sortable />
        <el-table-column prop="changeApproveNum" label="异动批准文号" align="center" sortable />
        <el-table-column prop="changedate" label="异动时间" align="center" sortable />
      </el-table>
    </div>
    <div v-if="tableIndex === 4" style="margin-top: 20px;">
      <el-table :data="tableData_drop" class="xpaas-table-class" row-class-name="xpaas-row-class" cell-class-name="xpaas-cell-class" header-row-class-name="xpaas-header-row-class" header-cell-class-name="xpaas-header-cell-class">
        <el-table-column prop="studentCode" label="学号" align="center" sortable />
        <el-table-column prop="studentname" label="姓名" align="center" sortable />
        <el-table-column prop="changedate" label="异动时间" align="center" sortable />
        <el-table-column prop="reason" label="原因" align="center" sortable />
        <el-table-column prop="originalSpecialty" label="原专业" align="center" sortable />
        <el-table-column prop="originalSpecialtyClassName" label="原专业班次" align="center" sortable />
        <el-table-column prop="changeApproveNum" label="异动批准文号" align="center" sortable />
        <el-table-column prop="changeTime" label="批准日期" align="center" sortable />
      </el-table>
    </div>
    <div v-if="tableIndex === 5" style="margin-top: 20px;">
      <el-table :data="tableData_punish" class="xpaas-table-class" row-class-name="xpaas-row-class" cell-class-name="xpaas-cell-class" header-row-class-name="xpaas-header-row-class" header-cell-class-name="xpaas-header-cell-class">
        <el-table-column prop="studentcode" label="学号" align="center" sortable />
        <el-table-column prop="studentname" label="姓名" align="center" sortable />
        <el-table-column prop="studentdui" label="学员队" align="center" sortable />
        <el-table-column prop="zybc" label="专业班次" align="center" sortable />
        <el-table-column prop="putype1" label="处分类别" align="center" sortable />
        <el-table-column prop="issudept" label="下达部门" align="center" sortable />
        <el-table-column prop="effdate" label="生效日期" align="center" sortable />
        <el-table-column prop="docno" label="下达文号" align="center" sortable />
        <el-table-column prop="reason" label="处分原因" align="center" sortable />
      </el-table>
    </div>
    <div v-if="tableIndex === 6" style="margin-top: 20px;">
      <el-table :data="tableData_reward" class="xpaas-table-class" row-class-name="xpaas-row-class" cell-class-name="xpaas-cell-class" header-row-class-name="xpaas-header-row-class" header-cell-class-name="xpaas-header-cell-class">
        <el-table-column prop="studentcode" label="学号" align="center" sortable />
        <el-table-column prop="studentname" label="姓名" align="center" sortable />
        <el-table-column prop="grade" label="奖励类别" align="center" sortable />
        <el-table-column prop="rddate" label="获奖日期" align="center" sortable />
        <el-table-column prop="fileno" label="奖励文件号" align="center" sortable />
        <el-table-column prop="money" label="奖励金额（元）" align="center" sortable />
        <el-table-column prop="reason" label="奖励原因" align="center" sortable />
      </el-table>
    </div>
    <div v-if="tableIndex === 7" style="margin-top: 20px;">
      <el-table :data="tableData_demotion" class="xpaas-table-class" row-class-name="xpaas-row-class" cell-class-name="xpaas-cell-class" header-row-class-name="xpaas-header-row-class" header-cell-class-name="xpaas-header-cell-class">
        <el-table-column prop="studentCode" label="学号" align="center" sortable />
        <el-table-column prop="studentname" label="姓名" align="center" sortable />
        <el-table-column prop="changedate" label="异动时间" align="center" sortable />
        <el-table-column prop="reason" label="原因" align="center" sortable />
        <el-table-column prop="originalSpecialty" label="原专业" align="center" sortable />
        <el-table-column prop="originalSpecialtyClassName" label="原专业班次" align="center" sortable />
        <el-table-column prop="changeApproveNum" label="异动批准文号" align="center" sortable />
        <el-table-column prop="changeTime" label="批准日期" align="center" sortable />
      </el-table>
    </div>
    <div v-if="tableIndex === 8" style="margin-top: 20px;">
      <el-table :data="tableData_transferSchool" class="xpaas-table-class" row-class-name="xpaas-row-class" cell-class-name="xpaas-cell-class" header-row-class-name="xpaas-header-row-class" header-cell-class-name="xpaas-header-cell-class">
        <el-table-column prop="studentname" label="学号" align="center" sortable />
        <el-table-column prop="studentname" label="姓名" align="center" sortable />
        <el-table-column prop="changedate" label="异动时间" align="center" sortable />
        <el-table-column prop="reason" label="原因" align="center" sortable />
        <el-table-column prop="originalSpecialty" label="原专业" align="center" sortable />
        <el-table-column prop="originalSpecialtyClassName" label="原专业班次" align="center" sortable />
        <el-table-column prop="changeApproveNum" label="异动批准文号" align="center" sortable />
        <el-table-column prop="changeTime" label="批准日期" align="center" sortable />
      </el-table>
    </div>
    <div style="float: right; margin: 10px 0;" v-if="tableIndex != 1">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :page-size="10"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>
    <div class="report-button" style="width: 120px; background: #fff6ef; border: 1px solid #f3b815; color: #f3b815; margin-top: 15px;">
      <img src="../../../assets/assessment/icon-export.png" />
      <download-excel
        :data="downloadData"
        :fields="jsonFields"
        type="xls"
        :name="excelName"
        style="color: #f3b815;">
        <span>导出Excel</span>
      </download-excel>
    </div>
  </div>
</template>

<script>
import { queryclassstuenttjmessage,querystudentinfo,queryzhuanzyinfo,querystudentinfotx,querystudentinfcf,querystudentinfjl,querystudentinfojj,querystudentinfoz } from '@/api/classHoursAddList/addList';
export default {
  data() {
    return {
      pageNo: 1,
      pageSize: 10,
      total: '',
      tableIndex: 1,
      excelName: '',
      downloadData: [],
      tableData_class: [],
      tableData_exist: [],
      tableData_transferMajor: [],
      tableData_drop: [],
      tableData_punish: [],
      tableData_reward: [],
      tableData_demotion: [],
      tableData_transferSchool: [],
      jsonFields: {
        '现有学员数': 'col1',
        '转专业数': 'col2',
        '退学数': 'col3',
        '处罚数': 'col4',
        '奖励数': 'col5',
        '降级数': 'col6',
        '转学数': 'col7'
      },
      speObj :{
        id:this.$route.query.id,
        pageNo:1,
        pageSize:10
      }
    }
  },
  mounted() {
    this.handleClassReport()
  },
  methods: {
    handleClassReport: function () {
      this.tableIndex = 1;
      queryclassstuenttjmessage(this.speObj).then(res=>{
        // if(res.data.data instanceof Array == false){
        //   this.$message({
        //     showClose: true,
        //     message: res.data.data,
        //     type: "error",
        //   });
        //   this.tableData_class = [];
        // } else {
        this.tableData_class.push(res.data.data);
        // this.tableData_class = res.data.data;
        this.total = this.tableData_class && this.tableData_class.length > 0 ? this.tableData_class[0].tol : '';
        // }
        this.excelName = '班学员统计信息.xls'
        this.jsonFields = {
          '现有学员数': 'studentsum',
          '转专业数': 'zzysum',
          '退学数': 'txsum',
          '处罚数': 'cfsum',
          '奖励数': 'jlsum',
          '降级数': 'jjsum',
          '转学数': 'zxsum'
        }
        this.downloadData = this.tableData_class
      })
    },
    handleExistReport: function () {
      this.tableIndex = 2;
      querystudentinfo(this.speObj).then(res=>{
        if(res.data.data instanceof Array == false){
          this.$message({
              showClose: true,
              message: res.data.data,
              type: "error",
          });
          this.tableData_exist = [];
        } else {
          this.tableData_exist = res.data.data;
          this.total = res.data.data && res.data.data.length > 0 ? res.data.data[0].tol : '';
        }
        this.excelName = '现有学员信息.xls'
        this.jsonFields = {
          '学号': 'studentCode',
          '姓名': 'studentName',
          '性别': 'gender',
          '出生日期': 'birthday',
          '专业': 'zy',
          '专业班次': 'specialtyClassName'
        }
        this.downloadData = this.tableData_exist
      })
    },
    handleTransferMajorReport: function () {
      this.tableIndex = 3;
      queryzhuanzyinfo(this.speObj).then(res=>{
        if(res.data.data instanceof Array == false){
        this.$message({
            showClose: true,
            message: res.data.data,
            type: "error",
          });
          this.tableData_transferMajor = [];
        } else {
          this.tableData_transferMajor = res.data.data;
          this.total = res.data.data && res.data.data.length > 0 ? res.data.data[0].tol : '';
        }
        this.excelName = '转专业学员信息.xls'
        this.jsonFields = {
          '学号': 'studentCode',
          '姓名': 'studentname',
          '现专业': 'xspecilty',
          '现专业班次': 'zybc',
          '原因': 'reason',
          '原专业': 'originalSpecialty',
          '原专业班次': 'originalSpecialtyClassName',
          '异动批准文号': 'changeApproveNum',
          '异动时间': 'changedate'
        }
        this.downloadData = this.tableData_transferMajor
      })
    },
    handleDropReport: function () {
      this.tableIndex = 4;
      querystudentinfotx(this.speObj).then(res=>{
        if(res.data.data instanceof Array == false){
        this.$message({
            showClose: true,
            message: res.data.data,
            type: "error",
          });
          this.tableData_drop = [];
        } else {
          this.tableData_drop = res.data.data;
          this.total = res.data.data && res.data.data.length > 0 ? res.data.data[0].tol : '';
        }
        this.excelName = '退学学员信息.xls'
        this.jsonFields = {
          '学号': 'studentCode',
          '姓名': 'studentname',
          '异动时间': 'changedate',
          '原因': 'reason',
          '原专业': 'originalSpecialty',
          '原专业班次': 'originalSpecialtyClassName',
          '异动批准文号': 'changeApproveNum',
          '批准日期': 'changeTime'
        }
        this.downloadData = this.tableData_drop
      })
    },
    handlePunishReport: function () {
      this.tableIndex = 5;
      querystudentinfcf(this.speObj).then(res=>{
        if(res.data.data instanceof Array == false){
        this.$message({
            showClose: true,
            message: res.data.data,
            type: "error",
          });
         this.tableData_punish = [];
        } else {
          this.tableData_punish = res.data.data;
          this.total = res.data.data && res.data.data.length > 0 ? res.data.data[0].tol : '';
        }
        this.excelName = '处罚学员信息.xls'
        this.jsonFields = {
          '学号': 'studentcode',
          '姓名': 'studentname',
          '学员队': 'studentdui',
          '专业班次': 'zybc',
          '处分类别': 'putype1',
          '下达部门': 'issudept',
          '生效日期': 'effdate',
          '下达文号': 'docno',
          '处分原因': 'reason'
        }
        this.downloadData = this.tableData_punish
      })
    },
    handleRewardReport: function () {
      this.tableIndex = 6;
      querystudentinfjl(this.speObj).then(res=>{
        if(res.data.data instanceof Array == false){
        this.$message({
            showClose: true,
            message: res.data.data,
            type: "error",
          });
         this.tableData_reward = [];
        } else {
          this.tableData_reward = res.data.data;
          this.total = res.data.data && res.data.data.length > 0 ? res.data.data[0].tol : '';
        }
        this.excelName = '奖励学员信息.xls'
        this.jsonFields = {
          '学号': 'studentcode',
          '姓名': 'studentname',
          '奖励类别': 'grade',
          '获奖日期': 'rddate',
          '奖励文件号': 'fileno',
          '奖励金额（元）': 'money',
          '奖励原因': 'reason'
        }
        this.downloadData = this.tableData_reward
      })
    },
    handleDemotionReport: function () {
      this.tableIndex = 7;
      querystudentinfojj(this.speObj).then(res=>{
        if(res.data.data instanceof Array == false){
        this.$message({
            showClose: true,
            message: res.data.data,
            type: "error",
          });
         this.tableData_demotion = [];
        } else {
          this.tableData_demotion = res.data.data;
          this.total = res.data.data && res.data.data.length > 0 ? res.data.data[0].tol : '';
        }
        this.excelName = '降级学员信息.xls'
        this.jsonFields = {
          '学号': 'studentCode',
          '姓名': 'studentname',
          '异动时间': 'changedate',
          '原因': 'reason',
          '原专业': 'originalSpecialty',
          '原专业班次': 'originalSpecialtyClassName',
          '异动批准文号': 'changeApproveNum',
          '批准日期': 'changeTime'
        }
        this.downloadData = this.tableData_demotion
      })
    },
    handleTransferSchoolReport: function () {
      this.tableIndex = 8;
      querystudentinfoz(this.speObj).then(res=>{
        if(res.data.data instanceof Array == false){
        this.$message({
            showClose: true,
            message: res.data.data,
            type: "error",
          });
         this.tableData_transferSchool = [];
        } else {
          this.tableData_transferSchool = res.data.data;
          this.total = res.data.data && res.data.data.length > 0 ? res.data.data[0].tol : '';
        }
        this.excelName = '转学学员信息.xls'
        this.jsonFields = {
          学号: 'studentCode',
          姓名: 'studentname',
          异动时间: 'changedate',
          原因: 'reason',
          原专业: 'originalSpecialty',
          原专业班次: 'originalSpecialtyClassName',
          异动批准文号: 'changeApproveNum',
          批准日期: 'changeTime'
        }
        this.downloadData = this.tableData_transferSchool
      })
    },
    handleSizeChange: function (val) {
      this.pageSize = val
    },
    handleCurrentChange: function (val) {
      this.pageNo = val
    }
  }
}
</script>

<style lang="less" scoped>
  .report-button {
    height: 28px;
    line-height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-right: 25px;
    img {
      width: 17px;
      height: 17px;
      background-size: 100% 100%;
      background-repeat: no-repeat;
      margin-right: 5px;
    }
  }
  @fontFamily:"Microsoft YaHei";
  .xpaas-table-class {
    border: 1px solid #004ca7;
    border-radius: 9px;
    ::v-deep div.el-table__header-wrapper {
      table.el-table__header {
        thead {
          tr.xpaas-header-row-class {
            padding: 0;
            height: 76px;
            background-color: #edf2f9;
            font-size: 16px;
            font-family: Microsoft YaHei;
            font-weight: bold;
            line-height: 20px;
            color: #004ca7;
            th.xpaas-header-cell-class {
              font-weight: bold;
              border-right: 1px solid #c7d7eb;
              border-left: 0;
              border-bottom: 1px solid #c7d7eb;
              background-color: #edf2f9;
              div.cell {
                font-size: 16px;
                font-weight: bold;
                font-family: @fontFamily;
                color: #004ca7;
              }
            }
          }
        }
      }
    }
    ::v-deep div.el-table__body-wrapper {
      table.el-table__body {
        tbody {
          tr.xpaas-row-class {
            td.xpaas-header-cell-class {
              border-right: 1px solid #c7d7eb;
              border-left: 0;
              border-bottom: 1px solid #c7d7eb;
              background-color: #edf2f9;
              div.cell {
                font-size: 16px;
                font-weight: bold;
                font-family: @fontFamily;
                color: #004ca7;
              }
            }
            td.xpaas-cell-class {
              height: 76px;
              border-right: 1px solid #c7d7eb;
              border-left: 0;
              border-bottom: 1px solid #c7d7eb;
              div.cell {
                font-weight: normal;
                font-family: @fontFamily;
                color: #004ca7;
              }
            }
          }
        }
      }
    }
  }
</style>
